package testenv.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import testenv.model.entity.Parent;
import testenv.service.ParentService;

@Service
@Transactional
public class ParentServiceImpl implements ParentService {
	
	@Autowired
	protected HibernateTemplate hibernateTemplate;

	
	@Override
	public void deleteParent(Integer parentId) {
		hibernateTemplate.delete(getParent(parentId));
	}

	@Override
	public Parent getParent(Integer parentId) {
		return (Parent)hibernateTemplate.get(Parent.class, parentId);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Parent> getParentList() {
		return hibernateTemplate.loadAll(Parent.class);
	}

	@Override
	public void saveParent(Parent parent) {
		hibernateTemplate.save(parent);
	}
	
	
}
